//C语言代码在此:
#include "STC15F2K60S2.h"
//#include "Help.h"
//#include "ASMtest.h"
#define Uint unsigned int
#define Byte unsigned char

void SerialSendByte(char dat)
{
	SBUF = dat;
	while(TI == 0);
	TI = 0;
}

void SerialSendStr(char *str)
{
	while(*str != '\0')
	{
		SerialSendByte(*str);
		str++;
	}
}

void Help()
{
	SerialSendStr("HELP\r\n");
}

void main()
{
	void (*TargetCommand)()=Help;

	{
		PCON &= 0x7F;		//波特率不倍速
		SCON = 0x50;		//8位数据,可变波特率
		AUXR |= 0x40;		//定时器1时钟为Fosc,即1T
		AUXR &= 0xFE;		//串口1选择定时器1为波特率发生器
		TMOD &= 0x0F;		//清除定时器1模式位
		TMOD |= 0x20;		//设定定时器1为8位自动重装方式
		TL1 = 0xF8;		//设定定时初值
		TH1 = 0xF8;		//设定定时器重装值
		ET1 = 0;		//禁止定时器1中断
		TR1 = 1;		//启动定时器1
	}
	
	SerialSendStr("Welcome to 51\r\n");

	TargetCommand();//<-------------此处会莫名其妙奔溃,导致CPU从头开始执行
}